package com.example.javasample.controller;

import com.example.javasample.domain.TenantDO;
import com.example.javasample.service.ITenantService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * TenantController
 *
 * @author Kylin
 */
@ApiSupport(order = 2)
@Tag(name = "租户")
@RestController
@RequestMapping("/tenant")
public class TenantController {

    @Autowired
    private ITenantService tenantService;

    @ApiOperationSupport(order = 1)
    @Operation(summary = "列表", description = "")
    @GetMapping(value = "/list")
    public List<TenantDO> list(@ParameterObject TenantDO tenant) {
        return tenantService.list(tenant);
    }

    @ApiOperationSupport(order = 2)
    @Operation(summary = "新增", description = "")
    @PostMapping("/add")
    public int add(@ParameterObject TenantDO tenant) {
        return tenantService.add(tenant);
    }

    @ApiOperationSupport(order = 3)
    @Operation(summary = "编辑", description = "")
    @PutMapping("/edit")
    public int edit(@ParameterObject TenantDO tenant) {
        return tenantService.edit(tenant);
    }

    @ApiOperationSupport(order = 4)
    @Operation(summary = "删除", description = "")
    @DeleteMapping("/delete/{tenantId}")
    public int delete(@PathVariable Long tenantId) {
        return tenantService.delete(tenantId);
    }

    @ApiOperationSupport(order = 5)
    @Operation(summary = "物理删除", description = "")
    @DeleteMapping("/physicallyDelete/{tenantId}")
    public int physicallyDelete(@PathVariable Long tenantId) {
        return tenantService.physicallyDelete(tenantId);
    }

}
